package com.ruoyi.web.controller.supervise;

import java.text.SimpleDateFormat;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.supervise.domain.ClSafetymeasuresinfo;
import com.ruoyi.supervise.service.IClSafetymeasuresinfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 施工许可-施工安全具体措施信息Controller
 * 
 * @author wtj
 * @date 2019-10-14
 */
@Controller
@RequestMapping("/supervise/SafetyMeasuresInfo")
public class ClSafetymeasuresinfoController extends BaseController
{
    private String prefix = "supervise/SafetyMeasuresInfo";

    @Autowired
    private IClSafetymeasuresinfoService clSafetymeasuresinfoService;

    @RequiresPermissions("supervise:SafetyMeasuresInfo:view")
    @GetMapping()
    public String SafetyMeasuresInfo()
    {
        return prefix + "/SafetyMeasuresInfo";
    }

    /**
     * 查询施工许可-施工安全具体措施信息列表
     */
    @RequiresPermissions("supervise:SafetyMeasuresInfo:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ClSafetymeasuresinfo clSafetymeasuresinfo)
    {
        startPage();
        List<ClSafetymeasuresinfo> list = clSafetymeasuresinfoService.selectClSafetymeasuresinfoList(clSafetymeasuresinfo);
        return getDataTable(list);
    }

    /**
     * 导出施工许可-施工安全具体措施信息列表
     */
    @RequiresPermissions("supervise:SafetyMeasuresInfo:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ClSafetymeasuresinfo clSafetymeasuresinfo)
    {
        List<ClSafetymeasuresinfo> list = clSafetymeasuresinfoService.selectClSafetymeasuresinfoList(clSafetymeasuresinfo);
        ExcelUtil<ClSafetymeasuresinfo> util = new ExcelUtil<ClSafetymeasuresinfo>(ClSafetymeasuresinfo.class);
        return util.exportExcel(list, "SafetyMeasuresInfo");
    }

    /**
     * 新增施工许可-施工安全具体措施信息
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存施工许可-施工安全具体措施信息
     */
    @RequiresPermissions("supervise:SafetyMeasuresInfo:add")
    @Log(title = "施工许可-施工安全具体措施信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ClSafetymeasuresinfo clSafetymeasuresinfo)
    {
        return toAjax(clSafetymeasuresinfoService.insertClSafetymeasuresinfo(clSafetymeasuresinfo));
    }

    /**
     * 修改施工许可-施工安全具体措施信息
     */
    @GetMapping("/edit/{guid}")
    public String edit(@PathVariable("guid") String guid, ModelMap mmap)
    {
        ClSafetymeasuresinfo clSafetymeasuresinfo = clSafetymeasuresinfoService.selectClSafetymeasuresinfoById(guid);
        mmap.put("clSafetymeasuresinfo", clSafetymeasuresinfo);
        return prefix + "/edit";
    }

    /**
     * 修改保存施工许可-施工安全具体措施信息
     */
    @RequiresPermissions("supervise:SafetyMeasuresInfo:edit")
    @Log(title = "施工许可-施工安全具体措施信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ClSafetymeasuresinfo clSafetymeasuresinfo)
    {
        return toAjax(clSafetymeasuresinfoService.updateClSafetymeasuresinfo(clSafetymeasuresinfo));
    }
    
    /**
     * 修改施工许可-施工安全具体措施信息
     */
    @GetMapping("/detail/{guid}")
    public String detail(@PathVariable("guid") String guid, ModelMap mmap)
    {
        ClSafetymeasuresinfo clSafetymeasuresinfo = clSafetymeasuresinfoService.selectClSafetymeasuresinfoById(guid);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String newPubdate=sdf.format(clSafetymeasuresinfo.getPubdate());
        mmap.put("newPubdate", newPubdate);
        mmap.put("clSafetymeasuresinfo", clSafetymeasuresinfo);
        return prefix + "/detail";
    }

    /**
     * 删除施工许可-施工安全具体措施信息
     */
    @RequiresPermissions("supervise:SafetyMeasuresInfo:remove")
    @Log(title = "施工许可-施工安全具体措施信息", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(clSafetymeasuresinfoService.deleteClSafetymeasuresinfoByIds(ids));
    }
}
